package main;

import java.io.IOException;

import org.msgpack.MessagePack;
/**
 * msgpack序列化
 * @author jinmiao
 *
 */
public class MsgPackSerialize implements ISerialize{
	
    private static final MessagePack msgpack = new MessagePack();
    
    public byte[] serialize(Object obj) {
	try {
		return msgpack.write(obj);
	} catch (IOException e) {
	    throw new RuntimeException(e);
	}
    }

    public <T> T unSerialize(byte[] byts, Class<T> t) {
	try {
	    return msgpack.read(byts, t);
	} catch (IOException e) {
	    throw new RuntimeException(e);
	}
    }
}
